<div ng-controller="CouponsCtrl" ng-init="addAction()">
    <ul class="sui-breadcrumb">
        <li><a href="#/coupons/list">{{'优惠券'| translate}}</a></li>
        <li class="active">
            {{!coupon_id?"创建":"edit"|translate}}
        </li>
    </ul>
    <form name="Tradeform" class="sui-form form-horizontal" novalidate>
        <div mywizard class="sui-steps">
            <step>
                <label><span class="round">1</span><span>优惠券设置</span></label>
                <i class="triangle-right-bg"></i><i class="triangle-right"></i>
            </step>
            <step ng-show="coupon_data.ptype == 2">
                <label><span class="round">2</span><span>设置商品</span></label>
                <i class="triangle-right-bg"></i><i class="triangle-right"></i>
            </step>
            <step>
                <label><span class="round">{{coupon_data.ptype == 1?2:3}}</span><span>完成</span></label>
                <i class="triangle-right-bg"></i><i class="triangle-right"></i>
            </step>
            <div stepcontent0 class="stepContent">
                <div class="stepbody">
                    <div class="control-group">
                        <label class="control-label">
                            优惠券标题：
                        </label>
                        <div class="controls">
                            <input id="title" type="text" name="name" ng-model="coupon_data.name" />
                            <div ng-show="coupon_data.name.length == 0 || coupon_data.name.length > 10" class="sui-msg msg-error msg-clear help-block error">
                                <div class="msg-con">活动标题不能超过10个字</div>
                                <s class="msg-icon"></s>
                            </div>
                        </div>
                    </div>
                    <!-- <div class="control-group">
                        <label class="control-label">
                            优惠券面额：
                        </label>
                        <div class="controls">
                            <input id="denomination" type="text" name="denomination" ng-model="coupon_data.denomination" /> 元
                        </div>
                    </div> -->
                    
                    <div class="control-group">
                        <label class="control-label v-top">
                            优惠券面额：
                        </label>
                        <div class="controls">
                            <ul id="tab-demo2" class="sui-nav nav-tabs nav-primary">
                                <li class="{{coupon_data.type_id == 1?'active':''}}"><a href="#default" data-toggle="tab" ng-click="tabCut($event);changeType(1);">打折</a></li>
                                <li class="{{coupon_data.type_id == 2?'active':''}}">
                                    <a href="#custom" data-toggle="tab" ng-click="tabCut($event);changeType(2)">
                                        减钱
                                    </a>
                                </li>
                            </ul>
                            <div class="tab-content">
                                <input type="hidden" ng-model="coupon_data.type_id" />
                                <div id="default" class="tab-pane {{coupon_data.type_id == 1?'active':''}}">
                                    打
                                    <input id="discount" type="text" name="discount" ng-model="coupon_data.discount" />
                                    <span class="help-inline">折</span>
                                    <span class="help-block" style="color:#f00;">举例：填95代表100元订单总额 95元支付；填50代表5折。</span>
                                </div>
                                <div id="custom" class="tab-pane {{coupon_data.type_id == 2?'active':''}}">
                                    减
                                    <input id="denomination" type="text" name="denomination" ng-model="coupon_data.denomination" /> 元
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">
                            起始时间：
                        </label>
                        <div class="controls">
                            <input id="start_time" ng-model="coupon_data.start_time" datetimepicker name="start_time" value="2017-05-21 12:12:15" required>
                            <span class="float_left" style="width:10px;">至</span>
                            <input id="end_time" ng-model="coupon_data.end_time" datetimepicker name="end_time" min-date="{{coupon_data.start_time}}" required>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            总张数：
                        </label>
                        <div class="controls">
                            <input id="coupon_count" type="text" name="coupon_count" ng-model="coupon_data.coupon_count" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            每个人领取数目：
                        </label>
                        <div class="controls">
                            <input id="person_limit_count" type="text" name="person_limit_count" ng-model="coupon_data.person_limit_count" />   <span class="sui-btn btn-link">默认为0，0则是不限制领取张数。</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            最低订单总额：
                        </label>
                        <div class="controls">
                            <input id="condition" type="text" name="condition" ng-model="coupon_data.condition" /> 元   <span class="sui-btn btn-link">默认为0，0则是不限制最低订单总额。</span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            优惠范围：
                        </label>
                        <div class="controls">
                            <label data-toggle="radio" class="radio-pretty inline {{coupon_data.ptype == 1?'checked':''}}">
                                <input type="radio" name="radio" ng-checked="{{coupon_data.ptype==1}}" ng-model="coupon_data.ptype"  ng-disabled="{{coupon_id&&coupon_data.ptype==2}}" value="1"><span>全店商品参加</span>
                            </label>
                            <label data-toggle="radio" class="radio-pretty inline {{coupon_data.ptype == 2?'checked':''}}">
                                <input type="radio" name="radio" ng-model="coupon_data.ptype" ng-checked="{{coupon_data.ptype==2}}" ng-disabled="{{coupon_id&&coupon_data.ptype==1}}" value="2"><span>部分商品参加</span>
                            </label>
                        </div>
                    </div>
                </div>
                <div>
                    <button class="sui-btn btn-primary" ng-click="couponAdd();" ng-show="coupon_data.ptype == 1">{{!coupon_id?"save":"edit"|translate}}</button>
                    <button ng-show="coupon_data.ptype == 2" type="button" id="next1" class="sui-btn btn-primary" mywizard-next ng-click="couponAdd('part');">{{'Next step'|translate}}</button>
                </div>
            </div>
            <div stepcontent1 class="stepContent">
                <div class="stepbody">
                    <ul id="tab-demo" class="sui-nav nav-tabs nav-primary">
                        <li class="{{total_count?'active':''}}"><a href="#default1" data-toggle="tab" ng-click="tabCut($event);">已参加({{total_count?total_count:chosedItems.length?chosedItems.length:0}})</a></li>
                        <li class="{{!total_count?'active':''}}">
                            <a href="#custom1" data-toggle="tab" ng-click="tabCut($event);choseBroadcast();">添加</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="default1" class="tab-pane {{total_count?'active':''}}">
                            <table class="sui-table table-bordered">
                                <thead>
                                    <tr>
                                        <th>{{"item_image"|translate}} </th>
                                        <th>{{"title"|translate}} </th>
                                        <th>{{"operation"|translate}}</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr ng-repeat="item in item_list">
                                        <td><img ng-src="{{item.img}}" class="item-image-80" /></td>
                                        <td>
                                            {{item.title}}
                                            <br> {{item.item_id}}
                                        </td>
                                        <td>
                                            <button class="sui-btn btn-danger" ng-click="couponItemDelete(item.id,item.coupon_id)">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <pager page-no="1" page-size="pageSize" total="total_count" get-data="mjsItemGet(pageNo)"></pager>
                        </div>
                        <div id="custom1" class="tab-pane {{!total_count?'active':''}}">
                            <choose-item item-check="itemdata(items)" is-chose-item="1" mult="yes" chosed-item="mjs_item_list" skushow="1"></choose-item>
                        </div>
                    </div>
                </div>
                <div>
                    <button type="button" class="sui-btn btn-primary" mywizard-previous>上一步</button>
                    <button type="button" class="sui-btn btn-primary" ng-click="chooseItemAdd(coupon_id);">保存</button>
                </div>
            </div>
        </div>
    </form>
</div>